import React from 'react';
import InputItem from '../../../components/InputItem';
import {Input,InputNumber, message} from 'antd';
const {TextArea}= Input
class NewProjectOne extends React.Component {
    constructor(props) {
        super(props);
        let storageData = JSON.parse(sessionStorage.getItem('newInnovationProject_one'))
        this.state = { datas:storageData||{} };
    }
    componentDidMount(){
        this.props.onRef(this)
    }
    handleChange=(datas)=>{
        this.setState({datas})
    }
    saveDatas=()=>{
        let {datas}=this.state
        if(!datas.projectName){
            message.error('请输入项目名称')
            return;
        }
        if(!datas.projectType){
            message.error('请输入项目类别')
            return;
        }
        if(!datas.implementationPlan){
            message.error('请输入实施方案')
            return;
        }
        if(!datas.approvalReasons){
            message.error('请输入立项原因')
            return;
        }
        if(!datas.researchDirection){
            message.error('请输入研究风向')
            return;
        }
        if(!datas.projectPoint){
            message.error('请输入项目要点')
            return;
        }
        sessionStorage.setItem('newInnovationProject_one',JSON.stringify(datas))
        return true

    }
    render() {
        const {datas} = this.state
        const columns=[
            {name:'项目名称',keyName:'projectName',valueType:'text',style:{width:600},value:datas.projectName},
            {name:'项目类别',keyName:'projectType',valueType:'text',style:{width:600},value:datas.projectType},
            {name:'实施方案',keyName:'implementationPlan',valueType:'textArea',style:{width:600},value:datas.implementationPlan},
            {name:'立项原因',keyName:'approvalReasons',valueType:'textArea',style:{width:600},value:datas.approvalReasons},
            {name:'研究方向',keyName:'researchDirection',valueType:'textArea',style:{width:600},value:datas.researchDirection},
            {name:'项目要点',keyName:'projectPoint',valueType:'textArea',style:{width:600},value:datas.projectPoint},  
        ]
        return (
            <div>
                <InputItem columns={columns} onChange={this.handleChange}/>
            </div>
        );
    }
}

export default NewProjectOne;